//
//  STSellersViewController.m
//  赛拓
//
//  Created by 王磊 on 8/7/16.
//  Copyright © 2016 立金所. All rights reserved.
//

#import "STSellersViewController.h"
#import "STTitleView.h"
#import "STRefreshTableView.h"
#import "STOrderBean.h"
@interface STSellersViewController ()<STBaseViewDelegate>

@property (nonatomic ,strong) STRefreshTableView *tableView;
@end

@implementation STSellersViewController

- (void)initSubviews {
    [super initSubviews];
    
    [self initTitleView];
    
    [self initTableView];
}

- (void)initTitleView {
    STTitleView *titleView = [STTitleView instance];
    
    titleView.frame = CGRectMake(0, 0,ST_SCREEN_WIDTH, 30);
    
    titleView.mDelegate = self;
    
    titleView.titles = @[@"全部",@"进行中",@"待发货",@"已完成"];
    
    titleView.font = ST_15_FONT;
    
    [self.view addSubview:titleView];
}
- (void)initTableView {
    STRefreshTableView *tableView = [STRefreshTableView instance];
    
    self.tableView = tableView;
    
    tableView.cellType = STCellTypeOrder;
    
    tableView.mDelegate = self;
    
    [self.view addSubview:tableView];
    
    tableView.frame = CGRectMake(0, 30, ST_SCREEN_WIDTH, CGRectGetHeight(self.view.frame) - 30 - ST_TOPLAYOUTGUIDE - 44);
    
}


- (void)loadData {
    
    NSArray *data = @[
                      @{
                          @"freight":@"20",
                          @"orderNum":@"1234123112",
                          @"total":@"1142",
                          @"state":@(1),
                          @"count":@"2",
                          
                          @"goods":@{
                                  
                                  @"imgUrl":@"http://7xwkri.com2.z0.glb.qiniucdn.com/p1.png",
                                  @"name":@"高岭土",
                                  @"price":@"15",
                                  @"time":@"123123123",
                                  @"cid":@"",
                                  @"type":@(1),
                                  @"enName":@"4-氨基-5-氯嘧啶",
                                  @"cas":@"1231",
                                  }
                          },
                      @{
                          @"freight":@"20",
                          @"orderNum":@"1234123112",
                          @"total":@"1142",
                          @"state":@(1),
                          @"count":@"2",
                          @"goods":@{
                                  
                                  @"imgUrl":@"http://7xwkri.com2.z0.glb.qiniucdn.com/p1.png",
                                  @"name":@"高岭土",
                                  @"price":@"15",
                                  @"time":@"123123123",
                                  @"cid":@"",
                                  @"type":@(1),
                                  
                                  }
                          },
                      @{
                          @"freight":@"20",
                          @"orderNum":@"1234123112",
                          @"total":@"1142",
                          @"state":@(1),
                          @"count":@"2",
                          @"goods":@{
                                  
                                  @"imgUrl":@"http://7xwkri.com2.z0.glb.qiniucdn.com/p1.png",
                                  @"name":@"高岭土",
                                  @"price":@"15",
                                  @"time":@"123123123",
                                  @"cid":@"",
                                  @"type":@(1),
                                  
                                  }
                          },
                      @{
                          @"freight":@"20",
                          @"orderNum":@"1234123112",
                          @"total":@"1142",
                          @"state":@(1),
                          @"count":@"2",
                          @"goods":@{
                                  
                                  @"imgUrl":@"http://7xwkri.com2.z0.glb.qiniucdn.com/p1.png",
                                  @"name":@"高岭土",
                                  @"price":@"15",
                                  @"time":@"123123123",
                                  @"cid":@"",
                                  @"type":@(1),
                                  
                                  }
                          }
                      
                      ];
    
    NSArray *array = [STOrderBean mj_objectArrayWithKeyValuesArray:data];
    
    [self.tableView updateData:array];
}
- (void)loadNewData {
    [self.tableView.mj_header endRefreshing];
    
}
- (void)onItemClick:(STItemClickType)itemType withData:(id)data forIndexPath:(NSIndexPath *)indexPath {
    switch (itemType) {
        case STItemClickTypeTitle:
        {
            
            
            
            
        }
            break;
        case STItemClickTypeItem: {
            
            
            
            
        }
            break;
        default:
            break;
    }
}

@end
